package com.nalai.market.v1.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nalai.market.v1.model.Order;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author com.nalai
 * @since 2021-08-23
 */
@Repository
public interface OrderMapper extends BaseMapper<Order> {

    @Select("select * from ordertable where ispay=1 and isconfirm=0")
    List<Order> getIsPayOrder();

    @Select("select * from ordertable where isconfirm=1 and issend=0")
    List<Order> getIsConfirmOrder();

    @Select("select * from ordertable where issend=1 and isreceive=0")
    List<Order> getIsSendOrder();

    @Select("select * from ordertable where isreceive=1 and isfinish=0")
    List<Order> getIsReceiveOrder();

    @Select("select * from ordertable where isfinish=1")
    List<Order> getIsFinishOrder();

    @Update("update ordertable set isconfirm=1 where id=#{id}")
    void operationConfirm(int id);

    @Update("update ordertable set issend=1 where id=#{id}")
    void operationSend(int id);

    @Update("update ordertable set isreceive=1 where id=#{id}")
    void operationReceive(int id);

    @Update("update ordertable set isfinish=1 where id=#{id}")
    void operationFinish(int id);

    @Delete("delete from ordertable where id=#{id}")
    void operationDelete(int id);
}
